package cn.edu.scau.cmi.linkaibo.client;

import cn.edu.scau.cmi.linkaibo.singleton.*; 
import javafx.application.*; 
import javafx.geometry.*; 
import javafx.scene.control.*; 
import javafx.scene.layout.*; 
import javafx.scene.paint.*; 
import javafx.scene.shape.*;
import javafx.scene.text.Font;
import javafx.scene.*; 
import javafx.stage.*; 
import javafx.event.*; 

public class SingletonClient extends Application{ 
    public static void main(String[] args) { 
        launch(args); // 启动JavaFX应用，接下来会跳到start方法 
    } 

@Override 

public void start(Stage stage) { 
	
    stage.setTitle("实验二"); 
    
    Pane pane=new Pane(); 
    
    singletonGUI(pane); 
    
    marshalGUI(pane); 
    
    Scene scene = new Scene(pane, 800, 400); 
    
    stage.setScene(scene); // 设置舞台的场景 
    
    stage.setResizable(false); // 设置舞台的尺寸是否允许变化 
    
    stage.show(); // 显示舞台。相当于JFrame的setVisible(true) 
} 

private void marshalGUI(Pane pane) {
	// TODO Auto-generated method stub
	
}

public void singletonGUI(Pane pane) { 
	
    Label label=new Label("单例模式"); 
    
    label.setFont(new Font(21));
    
    label.setLayoutX(10); 
    
    label.setLayoutY(25); 
    
    label.setPrefSize(160, 30); 
    
    pane.getChildren().add(label); 
    
    TextField field=new TextField(); 
   
    Label label1=new Label("请输入主席名字："); 
    
    label1.setLayoutX(10); 
    
    label1.setLayoutY(80); 
    
    label1.setPrefSize(160, 30); 
    
    pane.getChildren().add(label1); 
    
    TextField field1=new TextField(); 
    
    field1.setLayoutX(180); 
    
    field1.setLayoutY(80); 
    
    field1.setPrefSize(300,40); 
    
    pane.getChildren().add(field1); 

    TextArea textarea=new TextArea(); 
    
    textarea.setLayoutX(10); 
    
    textarea.setLayoutY(150); 
    
    pane.getChildren().add(textarea); 

    Button button1=new Button("确定创建"); 
    
    button1.setLayoutX(500); 
    
    button1.setLayoutY(80); 
    
    button1.setOnAction(new EventHandler<ActionEvent>() { // 设置按钮的单击事件 

  @Override 

  public void handle(ActionEvent arg0) { // 处理单击事件 
	  
      String name=field1.getText(); 
      
      textarea.appendText("主席姓名："+Chairman.getChairman(name).getName()+" "+Chairman.getChairman(name).toString()+"\n"); 
 } 
 }); 

 button1.setPrefSize(100, 40); 

pane.getChildren().add(button1); 

} 

}